<?php
echo $this->dojo()->enable()
             ->setDjConfigOption('parseOnLoad', true)
             ->setDjConfigOption('isDebug', false)
             ->setDjConfigOption('locale', 'zh');
?>

<script type="text/javascript">
    function changeImage()
    {
        dojo.xhrGet( {
            // The following URL must match that used to test the server.
            url: "<?php echo $this->U('user', 'ajax'); ?>",
            handleAs: "text",
            timeout: 5000, // Time in milliseconds

            // The LOAD function will be called on a successful response.
            load: function(response, ioArgs) {
                dojo.query("img", document.getElementById("captchaId")).forEach(
                    function(selectTag) {
                        if (selectTag.src.indexOf("<?php echo $this->captchaImageUrl; ?>")) {
                            selectTag.src = response;
                        }
                    }
                );
                
                return response;
            },

            // The ERROR function will be called in an error case.
            error: function(response, ioArgs) {
                console.error("HTTP status code: ", ioArgs.xhr.status);
                return response;
            }
        });
    }
</script>

<?php
echo $this->formLogin;
?>